#ifndef MYCHARTVIEW_H
#define MYCHARTVIEW_H

#include "QObject"
#include "QChartView"
#include "QTimer"
#include <QGraphicsSimpleTextItem>

class MyChartView : public QChartView
{
     Q_OBJECT

public:
    explicit MyChartView(QChart *chart, QWidget *parent = nullptr);

    // QWidget interface
protected:
    void mousePressEvent(QMouseEvent *event);

    // QWidget interface
protected:
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);

private:
    QPoint m_lastPoint;
    bool m_isPress;
    bool m_ctrlPress;
    bool m_alreadySaveRange;
    double m_xMin, m_xMax, m_yMin, m_yMax;
    QGraphicsSimpleTextItem* m_coordItem;

    bool isZoomed;
    void saveAxisRange();

    QTimer *zoomTimer;

private slots:
    void resetZoom();
};

#endif // MYCHARTVIEW_H
